<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			// while 循环
			var i = 10;
			while(i){
				document.writeln(i);
				i--;
			}
			// for 循环
			for(var i = 0; i < 10; i++){
				document.writeln(i);
			}
			// 数组
			var attr = [1,true,"hello"];
			for(var i = 0; i<attr.length;i++){
				document.writeln(attr[i]);
			}
			/* 数组长度可变,元素可以添加 */
			attr.push(4);
			for(var i = 0; i<attr.length;i++){
				document.writeln(attr[i]);
			}
			/*删除数组最后一个元素*/
			attr.pop();
			for(var i = 0; i<attr.length;i++){
				document.writeln(attr[i]);
			}
			
			//for-each 循环
			var attr2 = [10,20,30,-2];
			for(var temp in attr2){
				document.writeln(attr2[temp]);
			}
			//数组形式的定义拓展
			var attr3 = new Array(2);
			attr3[0] = 0;
			attr3[1] = 1;
			attr3[2] = 2;
			document.writeln("<hr>")
			for(var i = 0; i<attr3.length;i++){
				document.writeln(attr3[i]);
			}
			document.writeln("<hr>")
			document.writeln("attr3的数组长度是" + attr3.length);
		</script>
	</body>
</html>
